﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DaInterFace;
using DaInterFace.UMode;

namespace DataApplication.UMode
{
    public class UModeViewItem
    {
        ListViewItem lvi;
        public UModeViewItem(IUModeHole item)
        {
            lvi = new ListViewItem(item.PortName);
            ListViewItem.ListViewSubItem sbtype = new ListViewItem.ListViewSubItem(lvi, "料口");
            lvi.SubItems.Add(sbtype);
            ListViewItem.ListViewSubItem sbnote = new ListViewItem.ListViewSubItem(lvi, "正在连接...");
            lvi.SubItems.Add(sbnote);
            item.IMessageEvent += new DaInterFace.IMessageHandler(Message);
        }
        public UModeViewItem(IUModeGate item)
        {
            lvi = new ListViewItem(item.GateName);
            ListViewItem.ListViewSubItem sbtype = new ListViewItem.ListViewSubItem(lvi, "门禁");
            lvi.SubItems.Add(sbtype);
            ListViewItem.ListViewSubItem sbnote = new ListViewItem.ListViewSubItem(lvi, "正在连接...");
            lvi.SubItems.Add(sbnote);
            item.IMessageEvent += new DaInterFace.IMessageHandler(Message);
        }

        public void BingView(MyListView view)
        {
            view.Items.Insert(0, lvi);
        }

        public void Message(MessageType type, String note)
        {
            lvi.SubItems[2].Text = note;
            lvi.ToolTipText = note;
        }
    }
}
